﻿using System;
using System.Collections.Generic;
using System.Data;
using TidyBlog.Entity;
using TidyBlog.Data;

namespace TidyBlog.DAL
{
    /// <summary>
    /// 友情链接数据层
    /// </summary>
    public class LinkDAL
    {
        /// <summary>
        /// 创建友情链接
        /// </summary>
        /// <param name="link">友情链接</param>
        /// <returns>影响的行数</returns>
        public static int Create(Link link)
        {
            return SimpleORM<Link>.Insert(link);
        }

        /// <summary>
        /// 更新友情链接
        /// </summary>
        /// <param name="link">友情链接</param>
        /// <returns>影响的行数</returns>
        public static int Update(Link link)
        {
            return SimpleORM<Link>.Update(link);
        }

        /// <summary>
        /// 删除友情链接
        /// </summary>
        /// <param name="linkId">友情链接编号</param>
        /// <returns>影响的行数</returns>
        public static int Delete(int linkId)
        {
            return SimpleORM<Link>.Delete(
                new Link()
                {
                    LinkId = linkId
                }
            );
        }

        /// <summary>
        /// 读取友情链接列表
        /// </summary>
        /// <returns>友情链接列表</returns>
        public static Link[] List()
        {
            return SimpleORM<Link>.List().ToArray();
        }
    }
}
